import enum
import uuid
from datetime import datetime
from sqlalchemy import Column, BigInteger, String, Integer, SmallInteger, Date, DateTime, Enum, text, Numeric, Index, \
    UniqueConstraint
from core.database import Base

class PlatformType(str, enum.Enum):
    WECHAT = "wechat"
    WORK_WECHAT = "work_wechat"
    DOUYIN = "douyin"
    # 可以继续添加其他平台

class RelationStatus(str, enum.Enum):
    REQUESTING = "requesting"  # 添加中
    ADDED = "added"            # 已添加
    REJECTED = "rejected"      # 已拒绝
    FAILED = "failed"          # 添加失败
    # 可以继续添加其他状态

class CustomerPlatform(Base):
    __tablename__ = "customer_platform"
    id = Column(BigInteger, primary_key=True, autoincrement=True, comment='主键ID')
    customer_id = Column(String(36), comment='客户id')
    platform = Column(String(50), nullable=False, comment="平台标识")
    status = Column(String(50), nullable=False, comment="状态值")
    request_time = Column(DateTime, comment="发送好友请求的时间")
    added_time = Column(DateTime, comment="成为好友的时间")
    created_at = Column(DateTime, default=datetime.now, server_default=text('CURRENT_TIMESTAMP'), comment='创建时间')

    # 创建唯一约束和索引
    __table_args__ = (
        Index('idx_customer_id', 'customer_id'),
        UniqueConstraint('customer_id', 'platform', name='uq_customer_platform')  # 如果需要联合唯一也可以加上
    )